﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using YFIN.View.ViewModels;

namespace YFIN.View.MarketTrend
{
    public partial class Noble : UserControl
    {
        NobleVM _nvm;
        public Noble()
        {
            InitializeComponent();
            _nvm= new NobleVM();
            this.DataContext = _nvm; 
        }

        private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                var s = ((ComboBox)sender);
                if (MainDataGrid != null && chart != null)
                {
                    foreach (var c in MainDataGrid.Columns)
                    {
                        c.Visibility = Visibility.Collapsed;
                    }
                    MainDataGrid.Columns[0].Visibility = Visibility.Visible;
                    MainDataGrid.Columns[s.SelectedIndex + 1].Visibility = Visibility.Visible;
                    chart.CreateChart(_nvm.Noble, s.SelectedIndex);
                }
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            chart.CreateChart(_nvm.Noble, combobox.SelectedIndex);
        }
    }
}
